package network.api;

import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;

/**
 * @author mubei
 * @date 2021/12/5
 * @description
 */
public class Demo01 {

    public static void main(String[] args) throws Exception {
        InetAddress localHost = InetAddress.getLocalHost();
        System.out.println(localHost);
        //1. 域名
        System.out.println(InetAddress.getByName("www.baidu.com"));

        // 2. ip地址
        InetAddress byName = InetAddress.getByName("www.baidu.com");
        System.out.println(byName.getHostName());


    }
}
